
$(function(){

	//弹窗显示
    $(document).on("click",".addstaff-btn",function(){
    	$("[formTo='add_staff']").show();
    })
    .on("click",".addsection-btn",function(){
    	$("[formTo='add_section']").show();
    })
    .on("click",".addjob-btn",function(){
    	$("[formTo='add_job']").show();
    })
    .on("click",".addstation-btn",function(){
    	$("[formTo='add_station']").show();
    })

    $(document).on("click",".tip-btn",function(){
        var $this = $(this),
            tipStyle = $this.attr("tip");

        /*显示删除弹窗*/        
        if (tipStyle=="ask") {
            /*删除员工*/
            if($this.hasClass("delete-staff")){
                addTipHtml(
                    "ask", 
                    "是否确认删除该员工？",
                    "与该员工相关的数据也将被删除",
                    "删除",
                    "red",
                    function(){
                        addTipHtml(
                            "success", 
                            "员工删除成功！",
                            "",
                            "确定",
                            "green",
                            function(){
                                closeWindow();
                            }
                        );
                    },
                    "取消",
                    "gray",
                    function(){
                        closeWindow();
                    }
                );
            }
            /*删除部门*/
            if($this.hasClass("delete-section")){
                addTipHtml(
                    "ask", 
                    "是否确认删除该部门？",
                    "与该部门相关的数据也将被删除",
                    "删除",
                    "red",
                    function(){
                        addTipHtml(
                            "success", 
                            "部门删除成功！",
                            "",
                            "确定",
                            "green",
                            function(){
                                closeWindow();
                            }
                        );
                    },
                    "取消",
                    "gray",
                    function(){
                        closeWindow();
                    }
                );
            }
            /*删除职位*/
            if($this.hasClass("delete-job")){
                addTipHtml(
                    "ask", 
                    "是否确认删除该职位？",
                    "与该职位相关的数据也将被删除",
                    "删除",
                    "red",
                    function(){
                        addTipHtml(
                            "success", 
                            "职位删除成功！",
                            "",
                            "确定",
                            "green",
                            function(){
                                closeWindow();
                            }
                        );
                    },
                    "取消",
                    "gray",
                    function(){
                        closeWindow();
                    }
                );
            }
            /*删除站/所*/
            if($this.hasClass("delete-station")){
                addTipHtml(
                    "ask", 
                    "是否确认删除该站/所？",
                    "与该站/所相关的数据也将被删除",
                    "删除",
                    "red",
                    function(){
                        addTipHtml(
                            "success", 
                            "站/所删除成功！",
                            "",
                            "确定",
                            "green",
                            function(){
                                closeWindow();
                            }
                        );
                    },
                    "取消",
                    "gray",
                    function(){
                        closeWindow();
                    }
                );
            }
        }

        /*显示成功弹窗*/  
        if (tipStyle=="success" && checkWTip(this)){ 

            /*保存员工*/
            if ($this.hasClass("save-staff")) {
                //todo 提交

                addTipHtml(
                    "success", 
                    "员工信息保存成功！",
                    "",
                    "确定",
                    "green",
                    function(){
                        //todo 关闭执行方法
                         
                        closeWindow();
                    }
                );
            }
            /*保存部门*/
            if ($this.hasClass("save-section")) {
                addTipHtml(
                    "success", 
                    "部门信息保存成功！",
                    "",
                    "确定",
                    "green",
                    function(){
                        closeWindow();
                    }
                );
            }
            /*保存职位*/
            if ($this.hasClass("save-job")) {
                addTipHtml(
                    "success", 
                    "职位信息保存成功！",
                    "",
                    "确定",
                    "green",
                    function(){
                        closeWindow();
                    }
                );
            }
            /*保存站/所*/
            if ($this.hasClass("save-station")) {
                addTipHtml(
                    "success", 
                    "站/所信息保存成功！",
                    "",
                    "确定",
                    "green",
                    function(){
                        closeWindow();
                    }
                );
            }
        }
        
    });

})

